
// Source File Name:   STImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            STCommonImpl, ANYImpl, BLImpl, CSImpl, 
//            NullFlavorImpl, TYPEImpl

public class STImpl extends STCommonImpl
    implements ST
{

    public static final String RCS_ID = "$Header: STImpl.java 115.20 2005/09/16 09:22:58 amchanda noship $";
    private static final ST nullNI = new STImpl(CSImpl.valueOf("NI"));
    private static final ST nullOTH = new STImpl(CSImpl.valueOf("OTH"));
    private static final ST nullNINF = new STImpl(CSImpl.valueOf("NINF"));
    private static final ST nullPINF = new STImpl(CSImpl.valueOf("PINF"));
    private static final ST nullUNK = new STImpl(CSImpl.valueOf("UNK"));
    private static final ST nullASKU = new STImpl(CSImpl.valueOf("ASKU"));
    private static final ST nullNAV = new STImpl(CSImpl.valueOf("NAV"));
    private static final ST nullMSK = new STImpl(CSImpl.valueOf("MSK"));
    private static final ST nullNA = new STImpl(CSImpl.valueOf("NA"));
    private static final ST nullNASK = new STImpl(CSImpl.valueOf("NASK"));

    public static ST valueOf(String s)
    {
        return valueOf(s, null);
    }

    public static ST valueOf(String s, CS cs)
    {
        if(s == null || s.length() == 0)
            return new STImpl(NullFlavorImpl.NI);
        else
            return new STImpl(s, cs);
    }

    public static ST valueOf(char c)
    {
        return valueOf(String.valueOf(c));
    }

    protected STImpl(String s)
    {
        super(s);
    }

    protected STImpl(String s, CS cs)
    {
        super(s, cs);
    }

    protected STImpl(CS cs)
    {
        super(cs);
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.ST;
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof ST))
            return BLImpl.FALSE;
        if(isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        } else
        {
            ST st = (ST)any;
            return BLImpl.valueOf(stringValue().equals(st.stringValue()));
        }
    }

    public static ST nullST(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

	public byte[] byteArray() {
		// TODO Auto-generated method stub
		return null;
	}

}
